<span class="titulo">Credenciamento x Canal</span>
<?php
$link = sybase_connect('getbo', 'carga', 'carga2006') or die("Could not connect !");
$db = sybase_select_db('getbo', $link);
$sql = "SELECT DISTINCT
  dateformat(dt_pre_cadastro, 'dd/mm') as dia,
  count(distinct(cnpj)) as qt_ecs_credenciados,
  count(distinct(case when ds_status_adquirencia = 'APROVADO PELO BANCO' then cnpj else null end)) as qt_ecs_aprovados, 
  count(distinct(case when ds_status_adquirencia = 'REPROVADO PELO BANCO' then cnpj else null end)) as qt_ecs_rejeitados,
  count(distinct(case when ds_status_adquirencia = 'ENVIAR AO BANCO' then cnpj else null end)) as qt_ecs_enviar_massivo,
  count(distinct(case when cd_banco_credenciador is null then cnpj else null end)) as qt_ecs_getnet,
  count(distinct(case when cd_banco_credenciador = '033' then cnpj else null end)) as qt_ecs_santander,
  count(distinct(case when cd_banco_credenciador = '356' then cnpj else null end)) as qt_ecs_real
FROM
  DBA.D_CREDENCIAMENTO_ADQUIRENCIA
WHERE
  dt_pre_cadastro  BETWEEN  dateformat(dateadd(dd, -1, today()), 'yyyymm01') and dateformat(dateadd(dd, -1, today()), 'yyyymmdd')
group by
  dateformat(dt_pre_cadastro, 'dd/mm')";
$rs = sybase_query($sql, $link);
$FC2 = new FusionCharts("MSColumn3D", "1200", "300");
		
$FC2->setSwfPath("FusionChartsFree/Charts/");
		 
$strParam2="xAxisName=Meses;pYAxisName=Base Instalada;sYAxisName=Base Ativa;decimalPrecision=0;";
$FC2->addColors("4682B4;FF6347;32CD32");
$FC2->setChartParams($strParam2);

while ($linha = sybase_fetch_assoc($rs)) {
	$FC2->addCategory($linha["dia"]);
}	

$rs = sybase_query($sql, $link);
$FC2->addDataset("Getnet","showValues=1","decimalPrecision=5");
while ($linha = sybase_fetch_assoc($rs)) {
	$FC2->addChartData($linha["qt_ecs_getnet"]);	
}

$rs = sybase_query($sql, $link);
$FC2->addDataset("Santander","showValues=1");
while ($linha = sybase_fetch_assoc($rs)) {
	$FC2->addChartData($linha["qt_ecs_santander"]);
}

$rs = sybase_query($sql, $link);
$FC2->addDataset("Real","showValues=1");
while ($linha = sybase_fetch_assoc($rs)) {
	$FC2->addChartData($linha["qt_ecs_real"]);
}

$FC2->renderChart();

sybase_close($link);